package org.csu.logistics.Controller;

import org.csu.logistics.common.CommonResponse;
import org.csu.logistics.entity.User;
import org.csu.logistics.persistence.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@CrossOrigin(origins = "http://47.100.72.98:80")
@RequestMapping("/UserController/")
public class UserController {

    @Autowired
    UserMapper userMapper;

    //接口11 返回个人账户
    @PostMapping("/checkUser")
    @CrossOrigin(origins = "http://47.100.72.98:80")
    @ResponseBody
    public CommonResponse<User> select_userByUserId(@RequestBody Map<String,String> data){
        User user = userMapper.selectById(Integer.parseInt(data.get("userId")));
        if(user==null){
            return CommonResponse.createForError("没有该用户");
        }
        return CommonResponse.createForSuccess(user);
    }
}
